package com.hbq.teacher_plus.common.controller;

import cn.hutool.core.util.ObjectUtil;
import com.hbq.teacher_plus.util.MinioUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@CrossOrigin
@RestController
@Api(tags = "文件服务")
public class FileController {
    @ApiOperation(value = "上传文件返回url")
    @PostMapping("/upload")
    public String MinIOUpload(String bucketName, MultipartFile file) throws Exception {
        if (ObjectUtil.isEmpty(bucketName)) {
            bucketName = "file";
        }
        return MinioUtil.uploadPreview(bucketName, file);
    }

}
